﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NLog;
using System.Collections.Specialized;

namespace com.tiyma.iremoting
{
    public class AppUtil
    {
        /// <summary>
        /// 日志对象
        /// </summary>
        static Logger m_log = LogManager.GetLogger("sys_log");

        /// <summary>
        /// 错误日志
        /// </summary>
        /// <param name="i_text"></param>
        public static void Error(string i_text)
        {
            m_log.Error(i_text);
        }

        public static void Info(string i_text)
        {
            m_log.Info(i_text);
        }

        public static void Debug(string i_text)
        {
            m_log.Debug(i_text);
        }

        /// <summary>
        /// 索引文件路径根目录
        /// </summary>
        public static string BookIndexPath
        { get { return GetConfig("bookIndexPath", ""); } }

        #region 配置工具
        private static NameValueCollection _settings = null;

        public static NameValueCollection Settings
        {
            get { return AppUtil._settings; }
            set { AppUtil._settings = value; }
        }
        private static string GetConfig(string key, string defaultValue)
        {

            if (_settings == null)
                _settings = ConfigurationManager.AppSettings;

            if (Settings[key] != null)
                return Settings[key];
            else
                return defaultValue;

        }
        #endregion
    }
}
